package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.Assets;
import com.zygh.policeasset.pojo.AssetsCard;
import com.zygh.policeasset.pojo.AssetsTotal;
import com.zygh.policeasset.pojo.AssetsTypeSum;
import com.zygh.policeasset.pojo.Company;
import com.zygh.policeasset.pojo.DepRate;
import com.zygh.policeasset.pojo.export.ExportBasics;
import com.zygh.policeasset.pojo.export.ExportHardwit;
import com.zygh.policeasset.pojo.export.ExportPurchase;
import com.zygh.policeasset.pojo.export.ExportSoftWit;
import com.zygh.policeasset.pojo.imports.BasicsImport;
import com.zygh.policeasset.pojo.imports.DailyImport;
import com.zygh.policeasset.pojo.imports.HardwitImport;
import com.zygh.policeasset.pojo.imports.PurchaseImport;
import com.zygh.policeasset.pojo.imports.SoftwitImport;
import com.zygh.policeasset.pojo.vo.AssetsQrCodeVO;
import com.zygh.policeasset.pojo.vo.BeyondTheAssets;
import com.zygh.policeasset.pojo.vo.MonthListVO;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface AssetsMapper {
    @Insert({"insert into assets (asset_num,build_num,name,purchase_type,get_datetime,brand,retailer,asset_type_name,gaining_type,purpose,models,manufacturer,start_datetime,guarantee_stop_datetime,depreciation_year,money_type,number,unit_price,combined,depreciation_status,condition_status,use_department,place,use_user,manage_department,additional_number,pact_name,big_num,small_num,construc_unit,build_unit,completion_time,remark,facility_ip,responsible_police,power_type,whether_enable,whether_power,whether_network,soft_content,issue_type,soft_ip,normal_access,create_time,user_id,assets_status,assets_type,section_name,section_id,data_labels_id,start_provision_date,assets_classification_id,assets_classification_pid,self_built,quality_assurance,maintain_unit,development_unit,device_type,company_id,witbig_name,witsmall_name,build_unit_name,construc_unit_name,maintain_unit_name,assets_type_name,assets_status_name,asset_disposal_name,serial_number)  values(#{assetNum},#{buildNum},#{name},#{purchaseType},#{getDatetime}, #{brand},#{retailer}, #{assetTypeName},#{gainingType},#{purpose},#{models},#{manufacturer},#{startDatetime},#{guaranteeStopDatetime},#{depreciationYear},#{moneyType},#{number},#{unitPrice},#{combined},#{depreciationStatus},#{conditionStatus},#{useDepartment},#{place},#{useUser},#{manageDepartment},#{additionalNumber},#{pactName},#{bigNum},#{smallNum},#{construcUnit},#{buildUnit},#{completionTime},#{remark},#{facilityIp},#{responsiblePolice},#{powerType},#{whetherEnable},#{whetherPower},#{whetherNetwork},#{softContent},#{issueType},#{softIp},#{normalAccess},#{createTime},#{userId},#{assetsStatus},#{assetsType},#{sectionName},#{sectionId},#{dataLabelsId},#{startProvisionDate},#{assetsClassificationId},#{assetsClassificationPid},#{selfBuilt},#{qualityAssurance},#{maintainUnit},#{developmentUnit},#{deviceType},#{companyId},#{witbigName},#{witsmallName},#{buildUnitName},#{construcUnitName},#{maintainUnitName},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName},#{serialNumber})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int add(Assets assets);

    @Insert({"insert into assets(asset_num,pact_name,big_num,small_num,name,facility_ip,start_datetime,completion_time,unit_price,depreciation_year,quality_assurance,place,brand,models,responsible_police,construc_unit,build_unit,maintain_unit,power_type,whether_enable,whether_power,whether_network,remark,build_num,user_id,section_name,section_id,create_time,data_labels_id,assets_type,self_built,device_type,combined,company_id,witbig_name,witsmall_name,build_unit_name,construc_unit_name,maintain_unit_name,assets_type_name,assets_status_name,asset_disposal_name,qr_code) values(#{assetNum},#{pactName},#{bigNum},#{smallNum},#{name},#{facilityIp},#{startDatetime},#{completionTime},#{unitPrice},#{depreciationYear},#{qualityAssurance},#{place},#{brand},#{models},#{responsiblePolice},#{construcUnit},#{buildUnit},#{maintainUnit},#{powerType},#{whetherEnable},#{whetherPower},#{whetherNetwork},#{remark},#{buildNum},#{userId},#{sectionName},#{sectionId},#{createTime},#{dataLabelsId},#{assetsType},#{selfBuilt},#{deviceType},#{combined},#{companyId},#{bigName},#{smallName},#{buildUnitName},#{construcUnitName},#{maintainUnitName},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName},#{qrCode})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer addHardwit(HardwitImport hardwitImport);

    @Insert({"insert into assets(asset_num,pact_name,big_num,small_num,name,soft_content,issue_type,soft_ip,start_datetime,completion_time,unit_price,depreciation_year,quality_assurance,development_unit,responsible_police,build_unit,maintain_unit,construc_unit,whether_enable,normal_access,remark,build_num,user_id,section_name,section_id,create_time,data_labels_id,assets_type,self_built,device_type,combined,company_id,witbig_name,witsmall_name,build_unit_name,construc_unit_name,maintain_unit_name,assets_type_name,assets_status_name,asset_disposal_name) values(#{assetNum},#{pactName},#{bigNum},#{smallNum},#{name},#{softContent},#{issueType},#{softIp},#{startDatetime},#{completionTime},#{unitPrice},#{depreciationYear},#{qualityAssurance},#{developmentUnit},#{responsiblePolice},#{buildUnit},#{maintainUnit},#{construcUnit},#{whetherEnable},#{normalAccess},#{remark},#{buildNum},#{userId},#{sectionName},#{sectionId},#{createTime},#{dataLabelsId},#{assetsType},#{selfBuilt},#{deviceType},#{combined},#{companyId},#{bigName},#{smallName},#{buildUnitName},#{construcUnitName},#{maintainUnitName},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer addSoftwit(SoftwitImport softwitImport);

    @Insert({"insert into assets(asset_num,additional_number,pact_name,big_num,small_num,name,models,brand,number,unit_price,combined,construc_unit,build_unit,start_datetime,completion_time,depreciation_year,place,remark,build_num,user_id,section_name,section_id,create_time,data_labels_id,assets_type,self_built,device_type,company_id,witbig_name,witsmall_name,build_unit_name,construc_unit_name,assets_type_name,assets_status_name,asset_disposal_name,qr_code) values(#{assetNum},#{additionalNumber},#{pactName},#{bigNum},#{smallNum},#{name},#{models},#{brand},#{number},#{unitPrice},#{combined},#{construcUnit},#{buildUnit},#{startDatetime},#{completionTime},#{depreciationYear},#{place},#{remark},#{buildNum},#{userId},#{sectionName},#{sectionId},#{createTime},#{dataLabelsId},#{assetsType},#{selfBuilt},#{deviceType},#{companyId},#{bigName},#{smallName},#{buildUnitName},#{construcUnitName},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName},#{qrCode})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer addBasics(BasicsImport basicsImport);

    @Insert({"insert into assets(asset_num,pact_name,big_num,small_num,name,models,brand,number,unit_price,combined,construc_unit,build_unit,start_datetime,completion_time,depreciation_year,place,remark,build_num,user_id,section_name,section_id,create_time,data_labels_id,assets_type,self_built,company_id,device_type,witbig_name,witsmall_name,build_unit_name,construc_unit_name,assets_type_name,assets_status_name,asset_disposal_name,additional_number,qr_code) values(#{assetNum},#{pactName},#{bigNum},#{smallNum},#{name},#{models},#{brand},#{number},#{unitPrice},#{combined},#{construcUnit},#{buildUnit},#{startDatetime},#{completionTime},#{depreciationYear},#{place},#{remark},#{buildNum},#{userId},#{sectionName},#{sectionId},#{createTime},#{dataLabelsId},#{assetsType},#{selfBuilt},#{companyId},#{deviceType},#{bigName},#{smallName},#{buildUnitName},#{construcUnitName},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName},#{additionalNumber},#{qrCode})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer addDaily(DailyImport dailyImport);

    @Insert({"insert into assets(asset_num,name,purchase_type,get_datetime,brand,retailer,asset_type_name,gaining_type,purpose,models,manufacturer,start_datetime,guarantee_stop_datetime,depreciation_year,money_type,combined,depreciation_status,condition_status,use_department,place,use_user,manage_department,build_num,user_id,create_time,data_labels_id,assets_type,self_built,unit_price,company_id,serial_number,qr_code,assets_type_name,assets_status_name,asset_disposal_name) values(#{assetNum},#{name},#{purchaseType},#{getDatetime},#{brand},#{retailer},#{assetTypeName},#{gainingType},#{purpose},#{models},#{manufacturer},#{startDatetime},#{guaranteeStopDatetime},#{depreciationYear},#{moneyType},#{combined},#{depreciationStatus},#{conditionStatus},#{useDepartment},#{place},#{useUser},#{manageDepartment},#{buildNum},#{userId},#{createTime},#{dataLabelsId},#{assetsType},#{selfBuilt},#{unitPrice},#{companyId},#{serialNumber},#{qrCode},#{assetsTypeName},#{assetsStatusName},#{assetDisposalName})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer addPurchase(PurchaseImport purchaseImport);

    @Results(id = "map", value = {@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "asset_num", property = "assetNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "build_num", property = "buildNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "purchase_type", property = "purchaseType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "get_datetime", property = "getDatetime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "asset_type_name", property = "assetTypeName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "gaining_type", property = "gainingType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "start_datetime", property = "startDatetime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "guarantee_stop_datetime", property = "guaranteeStopDatetime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "depreciation_year", property = "depreciationYear", jdbcType = JdbcType.VARCHAR),
            @Result(column = "money_type", property = "moneyType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "unit_price", property = "unitPrice", jdbcType = JdbcType.VARCHAR),
            @Result(column = "depreciation_status", property = "depreciationStatus", jdbcType = JdbcType.VARCHAR),
            @Result(column = "condition_status", property = "conditionStatus", jdbcType = JdbcType.VARCHAR),
            @Result(column = "use_department", property = "useDepartment", jdbcType = JdbcType.VARCHAR),
            @Result(column = "use_user", property = "useUser", jdbcType = JdbcType.VARCHAR),
            @Result(column = "manage_department", property = "manageDepartment", jdbcType = JdbcType.VARCHAR),
            @Result(column = "additional_number", property = "additionalNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "pact_name", property = "pactName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "big_num", property = "bigNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "small_num", property = "smallNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "construc_unit", property = "construcUnit", jdbcType = JdbcType.VARCHAR),
            @Result(column = "build_unit", property = "buildUnit", jdbcType = JdbcType.VARCHAR),
            @Result(column = "completion_time", property = "completionTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "facility_ip", property = "facilityIp", jdbcType = JdbcType.VARCHAR),
            @Result(column = "responsible_police", property = "responsiblePolice", jdbcType = JdbcType.VARCHAR),
            @Result(column = "power_type", property = "powerType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "whether_enable", property = "whetherEnable", jdbcType = JdbcType.VARCHAR),
            @Result(column = "whether_power", property = "whetherPower", jdbcType = JdbcType.VARCHAR),
            @Result(column = "whether_network", property = "whetherNetwork", jdbcType = JdbcType.VARCHAR),
            @Result(column = "soft_content", property = "softContent", jdbcType = JdbcType.VARCHAR),
            @Result(column = "issue_type", property = "issueType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "soft_ip", property = "softIp", jdbcType = JdbcType.VARCHAR),
            @Result(column = "normal_access", property = "normalAccess", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "assets_status", property = "assetsStatus", jdbcType = JdbcType.VARCHAR),
            @Result(column = "section_name", property = "sectionName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "section_id", property = "sectionId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "data_labels_id", property = "dataLabelsId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "start_provision_date", property = "startProvisionDate", jdbcType = JdbcType.VARCHAR),
            @Result(column = "assets_classification_id", property = "assetsClassificationId", jdbcType = JdbcType.INTEGER),
            @Result(column = "assets_classification_pid", property = "assetsClassificationPid", jdbcType = JdbcType.INTEGER),
            @Result(column = "self_built", property = "selfBuilt", jdbcType = JdbcType.INTEGER),
            @Result(column = "quality_assurance", property = "qualityAssurance", jdbcType = JdbcType.VARCHAR),
            @Result(column = "maintain_unit", property = "maintainUnit", jdbcType = JdbcType.VARCHAR),
            @Result(column = "development_unit", property = "developmentUnit", jdbcType = JdbcType.VARCHAR),
            @Result(column = "assets_type", property = "assetsType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "asset_approval_status", property = "assetApprovalStatus", jdbcType = JdbcType.VARCHAR),
            @Result(column = "qr_code", property = "qrCode", jdbcType = JdbcType.VARCHAR),
            @Result(column = "witbig_name", property = "witbigName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "witsmall_name", property = "witsmallName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "build_unit_name", property = "buildUnitName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "construc_unit_name", property = "construcUnitName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "maintain_unit_name", property = "maintainUnitName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "assets_type_name", property = "assetsTypeName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "assets_status_name", property = "assetsStatusName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "asset_disposal_name", property = "assetDisposalName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "device_type", property = "deviceType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "qr_code_direct", property = "qrCodeDirect", jdbcType = JdbcType.VARCHAR),
            @Result(column = "qr_code_get_time", property = "qrCodeGetTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "serial_number", property = "serialNumber", jdbcType = JdbcType.VARCHAR)})
    @Select({"<script>select t.*,t6.name as assetsClassificationPName,t7.name as assetsClassificationName,t8.department_name as useDepartmentName,DATE_ADD(t.start_provision_date, INTERVAL depreciation_year YEAR) as endProvisionDate,CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) AS monthDepreciation,TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH)) AS haveDepreciationIn,TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH))*CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) AS accumulatedDepreciation,combined-TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH))*CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) as netWorth from assets t   LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   LEFT JOIN department t8 ON t.use_department= t8.department_num  <where>  <if test='id != null '> and t.id= #{id} </if><if test='assetNum != null and assetNum.length() &gt; 0'> and t.asset_num like concat('%',#{assetNum},'%')  </if><if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if><if test='name != null and name.length() &gt; 0'> and t.name like concat('%',#{name},'%') </if><if test='purchaseType != null and purchaseType.length() &gt; 0'> and t.purchase_type= #{purchaseType} </if><if test='getDatetime1 != null and getDatetime1.length() &gt; 0 and getDatetime2 != null and getDatetime2.length() &gt; 0'> and t.get_datetime between #{getDatetime1} and #{getDatetime2} </if><if test='brand != null and brand.length() &gt; 0'> and t.brand like concat('%',#{brand},'%')  </if><if test='retailer != null and retailer.length() &gt; 0'> and t.retailer like concat('%',#{retailer},'%')  </if>" +
            "<if test='assetTypeName != null and assetTypeName.length() &gt; 0'> and t.asset_type_name like concat('%',#{assetTypeName},'%')  </if>" +
            "<if test='gainingType != null and gainingType.length() &gt; 0'> and t.gaining_type= #{gainingType} </if>" +
            "<if test='purpose != null and purpose.length() &gt; 0'> and t.purpose like concat('%',#{purpose},'%')  </if>" +
            "<if test='models != null and models.length() &gt; 0'> and t.models like concat('%',#{models},'%')  </if>" +
            "<if test='manufacturer != null and manufacturer.length() &gt; 0'> and t.manufacturer like concat('%',#{manufacturer},'%')  </if>" +
            "<if test='startDatetime1 != null and startDatetime1.length() &gt; 0 and startDatetime2 != null and startDatetime2.length() &gt; 0'> and t.start_datetime between #{startDatetime1} and #{startDatetime2} </if>" +
            "<if test='depreciationYear != null '> and t.depreciation_year= #{depreciationYear} </if><if test='serialNumber != null and serialNumber.length() &gt; 0'> and t.serial_number= #{serialNumber} </if>" +
            "<if test='moneyType != null and moneyType.length() &gt; 0'> and t.money_type= #{moneyType} </if><if test='number != null '> and t.number= #{number} </if>" +
            "<if test='unitPrice != null'> and t.unit_price= #{unitPrice} </if>" +
            "<if test='combined != null'> and t.combined= #{combined} </if>" +
            "<if test='guaranteeStopDatetime != null and guaranteeStopDatetime.length &gt; 0'> and t.guarantee_stop_datetime = #{guaranteeStopDatetime} </if>" +
            "<if test='depreciationStatus != null and depreciationStatus.length() &gt; 0'> and t.depreciation_status= #{depreciationStatus} </if><if test='conditionStatus != null and conditionStatus.length() &gt; 0'> and t.condition_status= #{conditionStatus} </if>" +
            "<if test='useDepartment != null and useDepartment.length() &gt; 0'> and t.use_department = #{useDepartment} </if>" +
            "<if test='place != null and place.length() &gt; 0'> and t.place like concat('%',#{place},'%')  </if>" +
            "<if test='useUser != null and useUser.length() &gt; 0'> and t.use_user like concat('%',#{useUser},'%')  </if>" +
            "<if test='manageDepartment != null and manageDepartment.length() &gt; 0'> and t.manage_department like concat('%',#{manageDepartment},'%') </if><if test='additionalNumber != null and additionalNumber.length() &gt; 0'> and t.additional_number= #{additionalNumber} </if>" +
            "<if test='pactName != null and pactName.length() &gt; 0'> and t.pact_name like concat('%',#{pactName},'%')  </if><if test='bigNum != null and bigNum.length() &gt; 0'> and t.big_num= #{bigNum} </if><if test='smallNum != null and smallNum.length() &gt; 0'> and t.small_num= #{smallNum} </if>" +
            "<if test='construcUnit != null and construcUnit.length() &gt; 0'> and t.construc_unit= #{construcUnit} </if>" +
            "<if test='buildUnit != null and buildUnit.length() &gt; 0'> and t.build_unit= #{buildUnit} </if>" +
            "<if test='completionTime1 != null and completionTime1.length() &gt; 0 and completionTime2 != null and completionTime2.length() &gt; 0'> and t.completion_time between #{completionTime1} and #{completionTime2} </if><if test='remark != null and remark.length() &gt; 0'> and t.remark like concat('%',#{remark},'%')  </if><if test='facilityIp != null and facilityIp.length() &gt; 0'> and t.facility_ip= #{facilityIp} </if><if test='responsiblePolice != null and responsiblePolice.length() &gt; 0'> and t.responsible_police= #{responsiblePolice} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='whetherEnable != null'> and t.whether_enable= #{whetherEnable} </if><if test='whetherPower != null and whetherPower.length() &gt; 0'> and t.whether_power= #{whetherPower} </if><if test='whetherNetwork != null and whetherNetwork.length() &gt; 0'> and t.whether_network= #{whetherNetwork} </if><if test='softContent != null and softContent.length() &gt; 0'> and t.soft_content like concat('%',#{softContent},'%')</if><if test='issueType != null and issueType.length() &gt; 0'> and t.issue_type= #{issueType} </if><if test='softIp != null and softIp.length() &gt; 0'> and t.soft_ip like concat('%',#{softIp},'%')  </if><if test='normalAccess != null and normalAccess.length() &gt; 0'> and t.normal_access= #{normalAccess} </if><if test='createTime1 != null and createTime1.length() &gt; 0 and createTime2 != null and createTime2.length() &gt; 0'> and t.create_time between #{createTime1} and #{createTime2} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='userId != null'> and t.user_id= #{userId} </if><if test='assetsStatus != null '> and t.assets_status= #{assetsStatus} </if><if test='assetsType != null and assetsType.length() &gt; 0'> and t.assets_type like concat('%',#{assetsType},'%') </if><if test='sectionName != null and sectionName.length() &gt; 0'> and t.section_name like concat('%',#{sectionName},'%')  </if><if test='sectionId != null'> and t.section_id= #{sectionId} </if><if test='dataLabelsId != null'> and t.data_labels_id= #{dataLabelsId} </if><if test='startProvisionDate1 != null and startProvisionDate1.length() &gt; 0 and startProvisionDate2 != null and startProvisionDate2.length() &gt; 0'> and t.start_provision_date between #{startProvisionDate1} and #{startProvisionDate2} </if><if test='assetsClassificationId != null'> and t.assets_classification_id= #{assetsClassificationId} </if><if test='assetsClassificationPid != null'> and t.assets_classification_pid= #{assetsClassificationPid} </if><if test='selfBuilt != null '> and t.self_built= #{selfBuilt} </if><if test='qualityAssurance != null '> and t.quality_assurance= #{qualityAssurance} </if><if test='assetApprovalStatus != null '> and t.asset_approval_status= #{assetApprovalStatus} </if><if test='maintainUnit != null and maintainUnit.length() &gt; 0'> and t.maintain_unit = #{maintainUnit}  </if><if test='maintainUnitName != null and maintainUnitName.length() &gt; 0'> and t.maintain_unit_name like concat('%',#{maintainUnitName},'%')  </if><if test='construcUnitName != null and construcUnitName.length() &gt; 0'> and t.construc_unit_name like concat('%',#{construcUnitName},'%')   </if><if test='buildUnitName != null and buildUnitName.length() &gt; 0'> and t.build_unit_name like concat('%',#{buildUnitName},'%')  </if><if test='developmentUnit != null and developmentUnit.length() &gt; 0'> and t.development_unit like concat('%',#{developmentUnit},'%')  </if><if test='witbigAssetsType != null and witbigAssetsType.length() &gt; 0'> and t.device_type = #{witbigAssetsType}  </if><if test='qrCode != null and qrCode.length() &gt; 0'> and t.qr_code = #{qrCode}  </if><if test='assetDisposal != null'> and t.asset_disposal = #{assetDisposal}  </if><if test='lightGetBuildNum != null and lightGetBuildNum.length &gt; 0'> and light_get_build_num = #{lightGetBuildNum}  </if><if test='lightGetSectionId != null and lightGetSectionId.length &gt; 0'> and light_get_section_id = #{lightGetSectionId}  </if><if test='sectionName != null and sectionName.length &gt; 0'> and section_name = #{sectionName}  </if><if test='projectId == 0 '> and light_get_build_num is null  and assets_status > -1</if><if test='whetherSet == 0'>AND t.assets_classification_id IS  NULL </if>" +
            "<if test='whetherSet == 1'>AND t.assets_classification_id IS NOT NULL </if>" +
            "<if test='qrCodeWhether == 0'>AND t.qr_code IS NULL </if>" +
            "<if test='normalAssets == 1'> AND t.assets_status > -1 </if>" +
            "<if test='qrCodeWhether == 1'>AND t.qr_code IS NOT NULL </if>" +
            "<if test='qrCodeDirect != null '>AND t.qr_code_direct = #{qrCodeDirect} </if>" +
            "<if test='qrCodeGetTime1 != null and qrCodeGetTime1.length() &gt; 0 and qrCodeGetTime2 != null " +
            "and qrCodeGetTime2.length() &gt; 0'> and t.qr_code_get_time between #{qrCodeGetTime1} and #{qrCodeGetTime2} </if>" +
            "<if test='exclude == 1 '> AND (t.name not like '%辅警通%') " +
            " and (t.name not like '%执法记录仪%') and (t.name not like '%电台%') " +
            " and (t.name not like '%对讲机%') </if>" +
            "</where> " +
            "ORDER BY t.id DESC " +
            "</script>"})
    List<Assets> findAll(Assets assets);

    @ResultMap({"map"})
    @Select({"<script>select t.*,t6.name as assetsClassificationPName,t7.name as assetsClassificationName,t8.department_name as useDepartmentName,DATE_ADD(t.start_provision_date, INTERVAL depreciation_year YEAR) as endProvisionDate,CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) AS monthDepreciation,TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH)) AS haveDepreciationIn,TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH))*CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) AS accumulatedDepreciation,combined-TIMESTAMPDIFF(MONTH,start_provision_date,DATE_SUB(CURDATE(),INTERVAL -1 MONTH))*CONVERT(combined/(depreciation_year*12),DECIMAL(15,2)) as netWorth from assets t   LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   LEFT JOIN department t8 ON t.use_department= t8.department_num  <where>  <if test='id != null '> and t.id= #{id} </if><if test='assetsStatus != null '> and t.assets_status= #{assetsStatus} </if><if test='assetNum != null and assetNum.length() &gt; 0'> and t.asset_num like concat('%',#{assetNum},'%')  </if><if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if><if test='name != null and name.length() &gt; 0'> and t.name like concat('%',#{name},'%') </if><if test='purchaseType != null and purchaseType.length() &gt; 0'> and t.purchase_type= #{purchaseType} </if><if test='getDatetime1 != null and getDatetime1.length() &gt; 0 and getDatetime2 != null and getDatetime2.length() &gt; 0'> and t.get_datetime between #{getDatetime1} and #{getDatetime2} </if><if test='brand != null and brand.length() &gt; 0'> and t.brand like concat('%',#{brand},'%')  </if><if test='retailer != null and retailer.length() &gt; 0'> and t.retailer like concat('%',#{retailer},'%')  </if><if test='assetTypeName != null and assetTypeName.length() &gt; 0'> and t.asset_type_name like concat('%',#{assetTypeName},'%')  </if><if test='gainingType != null and gainingType.length() &gt; 0'> and t.gaining_type= #{gainingType} </if><if test='purpose != null and purpose.length() &gt; 0'> and t.purpose like concat('%',#{purpose},'%')  </if><if test='models != null and models.length() &gt; 0'> and t.models like concat('%',#{models},'%')  </if><if test='manufacturer != null and manufacturer.length() &gt; 0'> and t.manufacturer like concat('%',#{manufacturer},'%')  </if><if test='startDatetime1 != null and startDatetime1.length() &gt; 0 and startDatetime2 != null and startDatetime2.length() &gt; 0'> and t.start_datetime between #{startDatetime1} and #{startDatetime2} </if><if test='depreciationYear != null '> and t.depreciation_year= #{depreciationYear} </if><if test='serialNumber != null and serialNumber.length() &gt; 0'> and t.serial_number= #{serialNumber} </if><if test='moneyType != null and moneyType.length() &gt; 0'> and t.money_type= #{moneyType} </if><if test='number != null '> and t.number= #{number} </if><if test='unitPrice != null'> and t.unit_price= #{unitPrice} </if><if test='combined != null'> and t.combined= #{combined} </if><if test='depreciationStatus != null and depreciationStatus.length() &gt; 0'> and t.depreciation_status= #{depreciationStatus} </if><if test='conditionStatus != null and conditionStatus.length() &gt; 0'> and t.condition_status= #{conditionStatus} </if><if test='useDepartment != null and useDepartment.length() &gt; 0'> and t.use_department like concat('%',#{useDepartment},'%')  </if><if test='place != null and place.length() &gt; 0'> and t.place like concat('%',#{place},'%')  </if><if test='useUser != null and useUser.length() &gt; 0'> and t.use_user like concat('%',#{useUser},'%')  </if><if test='manageDepartment != null and manageDepartment.length() &gt; 0'> and t.manage_department= #{manageDepartment} </if><if test='additionalNumber != null and additionalNumber.length() &gt; 0'> and t.additional_number= #{additionalNumber} </if><if test='pactName != null and pactName.length() &gt; 0'> and t.pact_name like concat('%',#{pactName},'%')  </if><if test='bigNum != null and bigNum.length() &gt; 0'> and t.big_num= #{bigNum} </if><if test='smallNum != null and smallNum.length() &gt; 0'> and t.small_num= #{smallNum} </if><if test='construcUnit != null and construcUnit.length() &gt; 0'> and t.construc_unit= #{construcUnit} </if><if test='buildUnit != null and buildUnit.length() &gt; 0'> and t.build_unit= #{buildUnit} </if><if test='completionTime1 != null and completionTime1.length() &gt; 0 and completionTime2 != null and completionTime2.length() &gt; 0'> and t.completion_time between #{completionTime1} and #{completionTime2} </if><if test='remark != null and remark.length() &gt; 0'> and t.remark like concat('%',#{remark},'%')  </if><if test='facilityIp != null and facilityIp.length() &gt; 0'> and t.facility_ip= #{facilityIp} </if><if test='responsiblePolice != null and responsiblePolice.length() &gt; 0'> and t.responsible_police= #{responsiblePolice} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='whetherEnable != null '> and t.whether_enable= #{whetherEnable} </if><if test='whetherPower != null and whetherPower.length() &gt; 0'> and t.whether_power= #{whetherPower} </if><if test='whetherNetwork != null and whetherNetwork.length() &gt; 0'> and t.whether_network= #{whetherNetwork} </if><if test='softContent != null and softContent.length() &gt; 0'> and t.soft_content= #{softContent} </if><if test='issueType != null and issueType.length() &gt; 0'> and t.issue_type= #{issueType} </if><if test='softIp != null and softIp.length() &gt; 0'> and t.soft_ip like concat('%',#{softIp},'%')  </if><if test='normalAccess != null and normalAccess.length() &gt; 0'> and t.normal_access= #{normalAccess} </if><if test='createTime1 != null and createTime1.length() &gt; 0 and createTime2 != null and createTime2.length() &gt; 0'> and t.create_time between #{createTime1} and #{createTime2} </if><if test='powerType != null and powerType.length() &gt; 0'> and t.power_type= #{powerType} </if><if test='userId != null'> and t.user_id= #{userId} </if><if test='assetsType != null and assetsType.length() &gt; 0'> and t.assets_type= #{assetsType} </if><if test='sectionName != null and sectionName.length() &gt; 0'> and t.section_name like concat('%',#{sectionName},'%')  </if><if test='sectionId != null'> and t.section_id= #{sectionId} </if><if test='dataLabelsId != null'> and t.data_labels_id= #{dataLabelsId} </if><if test='startProvisionDate1 != null and startProvisionDate1.length() &gt; 0 and startProvisionDate2 != null and startProvisionDate2.length() &gt; 0'> and t.start_provision_date between #{startProvisionDate1} and #{startProvisionDate2} </if><if test='assetsClassificationId != null'> and t.assets_classification_id= #{assetsClassificationId} </if><if test='assetsClassificationPid != null'> and t.assets_classification_pid= #{assetsClassificationPid} </if><if test='selfBuilt != null '> and t.self_built= #{selfBuilt} </if><if test='qualityAssurance != null '> and t.quality_assurance= #{qualityAssurance} </if><if test='maintainUnit != null and maintainUnit.length() &gt; 0'> and t.maintain_unit = #{maintainUnit}  </if><if test='developmentUnit != null and developmentUnit.length() &gt; 0'> and t.development_unit like concat('%',#{developmentUnit},'%')  </if><if test='witbigAssetsType != null and witbigAssetsType.length() &gt; 0'> and t.device_type = #{witbigAssetsType}  </if><if test='qrCode != null and qrCode.length() &gt; 0'> and t.qr_code = #{qrCode}  </if><if test='assetDisposal != null'> and t.asset_disposal = #{assetDisposal}  </if><if test='lightGetBuildNum != null and lightGetBuildNum.length &gt; 0'> and light_get_build_num = #{lightGetBuildNum}  </if><if test='lightGetSectionId != null and lightGetSectionId.length &gt; 0'> and light_get_section_id = #{lightGetSectionId}  </if><if test='projectId == 0 '> and light_get_build_num is null  </if><if test='whetherSet == 0'>AND t.assets_classification_id IS  NULL </if><if test='whetherSet == 1'>AND t.assets_classification_id IS NOT NULL </if>and start_provision_date IS NOT NULL  and start_provision_date != ''  and DATE_ADD( t.start_provision_date, INTERVAL depreciation_year YEAR ) BETWEEN start_provision_date  and now() </where> ORDER BY t.id DESC </script>"})
    List<Assets> beyondThe(Assets assets);

    @Select({"<script>select t.id,t.name,t.asset_num,t.start_provision_date as startProvisionDate,t.depreciation_year as depreciationYear, DATE_ADD(t.start_provision_date, INTERVAL depreciation_year YEAR) as endProvisionDate from assets t   LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   LEFT JOIN department t8 ON t.use_department= t8.department_num  <where>   start_provision_date IS NOT NULL  AND start_provision_date != ''  AND DATE_ADD( t.start_provision_date, INTERVAL depreciation_year YEAR ) BETWEEN start_provision_date  AND now() </where> ORDER BY t.id DESC </script>"})
    List<BeyondTheAssets> pushBeyondTheAssets();

    @Select({"<script>" +
            "select t.id,t.asset_num as assetNum,t.name,t.purchase_type AS purchaseType," +
            "t.brand,t.assets_type_name AS assetsTypeName,t.build_num as buildNum,t.assets_type as assetsType," +
            "t.models,t.start_datetime AS startDatetime,t.witbig_name AS witbigName,t.witsmall_name AS witsmallName,t.place," +
            "t6.name as assetsClassificationPName," +
            "t7.name as assetsClassificationName,t8.department_name as useDepartmentName from assets t   " +
            "LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   " +
            "LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   " +
            "LEFT JOIN department t8 ON t.use_department= t8.department_num  " +
            "<where>  " +
            "<if test='qrCode != null and qrCode.length() &gt; 0'> and t.qr_code = #{qrCode} </if>" +
            "</where> " +
            "ORDER BY t.id DESC " +
            "</script>"})
    AssetsQrCodeVO selectByQrCode(String str);

    @Select({"<script>select sum(combined) from assets t  <where>  <if test='buildNum != null and buildNum.length() &gt; 0'>  build_num= #{buildNum} </if><if test='name != null and name.length() &gt; 0'> and name like concat('%',#{name},'%') </if><if test='assetsStatus != null '> and assets_status= #{assetsStatus} </if><if test='assetsType != null and assetsType.length() &gt; 0'> and assets_type= #{assetsType} </if><if test='sectionId != null'> and section_id= #{sectionId} </if><if test='whetherSet == 0'>AND assets_classification_id IS  NULL </if><if test='whetherSet == 1'>AND assets_classification_id IS NOT NULL </if></where> ORDER BY t.id DESC </script>"})
    Double selectCombined(@Param("whetherSet") Integer num, @Param("assetsType") String str, @Param("buildNum") String str2, @Param("name") String str3, @Param("sectionId") Integer num2, @Param("assetsStatus") Integer num3);

    @ResultMap({"map"})
    @Select({"<script>select t.*,t8.dict_name as assetsTypeName,t1.witbig_name as witbigName,t2.witsmall_name as witsmallName,t3.unit_name as buildUnitName ,t4.unit_name as construcUnitName,t5.unit_name as maintainUnitName,t6.name as assetsClassificationPName, t7.name as assetsClassificationName,t8.dict_name as assetsTypeName,t9.dict_name as assetsStatusName,t10.dict_name as assetDisposalName from assets t   LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num and t2.type= t.device_type LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num and t5.TYPE = t.device_type  LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'assetsType') t8 ON t.assets_type= t8.dict_value   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'assetsStatus') t9 ON t.assets_status= t9.dict_value   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'asset_disposal') t10 ON t.asset_disposal= t10.dict_value  <where> <if test='id != null '> and t.id= #{id} </if></where>  </script>"})
    Assets findById(Integer num);

    @ResultMap({"map"})
    @Select({"<script>select t.*,t8.dict_name as assetsTypeName,t1.witbig_name as witbigName,t2.witsmall_name as witsmallName,t3.unit_name as buildUnitName ,t4.unit_name as construcUnitName,t5.unit_name as maintainUnitName,t6.name as assetsClassificationPName, t7.name as assetsClassificationName,t8.dict_name as assetsTypeName,t9.dict_name as assetsStatusName,t10.dict_name as assetDisposalName from assets t   LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num and t2.type= t.device_type LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num and t5.TYPE = t.device_type  LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'assetsType') t8 ON t.assets_type= t8.dict_value   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'assetsStatus') t9 ON t.assets_status= t9.dict_value   LEFT JOIN (SELECT *  FROM dict_data WHERE dict_type = 'asset_disposal') t10 ON t.asset_disposal= t10.dict_value  <where>  t.id in <foreach collection='ids' item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach></where>  </script>"})
    List<Assets> findByIds(@Param("ids") String[] strArr);

    @Select({"<script>select t.asset_num as assetNum,t4.unit_name as construcUnitName,t6.unit_name as useDepartment,t1.witbig_name as witbigName,t2.witsmall_name as witsmallName,t.asset_type_name as assetTypeNameCg,t.start_datetime as startDatetime,t.combined,t.depreciation_year as depreciationYear,t.brand,t3.unit_name as buildUnitName,t.assets_type as assetsType,t5.connect as url,t.name,t.place,t.models,t.manufacturer from assets t   LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num and t2.type= t.device_type LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   LEFT JOIN assets_images t5 ON t.id= t5.assets_id   LEFT JOIN unit t6 ON t.use_department = t6.unit_num  and t6.TYPE = t.assets_type<where>  <if test='assetId != null '> and t.id= #{assetId} </if></where>  </script>"})
    AssetsCard assetsCardQuery(Integer num);

    @Update({"<script>update assets <set> <if test='assetNum != null and assetNum.length &gt; 0'>asset_num = #{assetNum},</if><if test='buildNum != null and buildNum.length &gt; 0'>build_num = #{buildNum},</if><if test='name != null and name.length &gt; 0'>name = #{name},</if><if test='purchaseType != null and purchaseType.length &gt; 0'>purchase_type = #{purchaseType},</if><if test='getDatetime != null and getDatetime.length &gt; 0'>get_datetime = #{getDatetime},</if><if test='brand != null and brand.length &gt; 0'>brand = #{brand},</if><if test='retailer != null and retailer.length &gt; 0'>retailer = #{retailer},</if><if test='assetTypeName != null and assetTypeName.length &gt; 0'>asset_type_name = #{assetTypeName},</if><if test='gainingType != null and gainingType.length &gt; 0'>gaining_type = #{gainingType},</if><if test='purpose != null and purpose.length &gt; 0'>purpose = #{purpose},</if><if test='models != null and models.length &gt; 0'>models = #{models},</if><if test='manufacturer != null and manufacturer.length &gt; 0'>manufacturer = #{manufacturer},</if><if test='startDatetime != null and startDatetime.length &gt; 0'>start_datetime = #{startDatetime},</if><if test='guaranteeStopDatetime != null and guaranteeStopDatetime.length &gt; 0'>guarantee_stop_datetime = #{guaranteeStopDatetime},</if><if test='depreciationYear != null '>depreciation_year = #{depreciationYear},</if><if test='moneyType != null and moneyType.length &gt; 0'>money_type = #{moneyType},</if><if test='number != null '>number = #{number},</if><if test='unitPrice != null '>unit_price = #{unitPrice},</if><if test='combined != null '>combined = #{combined},</if><if test='depreciationStatus != null and depreciationStatus.length &gt; 0'>depreciation_status = #{depreciationStatus},</if><if test='conditionStatus != null and conditionStatus.length &gt; 0'>condition_status = #{conditionStatus},</if><if test='useDepartment != null and useDepartment.length &gt; 0'>use_department = #{useDepartment},</if><if test='place != null and place.length &gt; 0'>place = #{place},</if><if test='useUser != null and useUser.length &gt; 0'>use_user = #{useUser},</if><if test='manageDepartment != null and manageDepartment.length &gt; 0'>manage_department = #{manageDepartment},</if><if test='additionalNumber != null and additionalNumber.length &gt; 0'>additional_number = #{additionalNumber},</if><if test='pactName != null and pactName.length &gt; 0'>pact_name = #{pactName},</if><if test='bigNum != null and bigNum.length &gt; 0'>big_num = #{bigNum},</if><if test='smallNum != null and smallNum.length &gt; 0'>small_num = #{smallNum},</if><if test='construcUnit != null and construcUnit.length &gt; 0'>construc_unit = #{construcUnit},</if><if test='buildUnit != null and buildUnit.length &gt; 0'>build_unit = #{buildUnit},</if><if test='completionTime != null and completionTime.length &gt; 0'>completion_time = #{completionTime},</if><if test='remark != null and remark.length &gt; 0'>remark = #{remark},</if><if test='facilityIp != null and facilityIp.length &gt; 0'>facility_ip = #{facilityIp},</if><if test='responsiblePolice != null and responsiblePolice.length &gt; 0'>responsible_police = #{responsiblePolice},</if><if test='powerType != null and powerType.length &gt; 0'>power_type = #{powerType},</if><if test='whetherEnable != null '>whether_enable = #{whetherEnable},</if><if test='whetherPower != null and whetherPower.length &gt; 0'>whether_power = #{whetherPower},</if><if test='whetherNetwork != null and whetherNetwork.length &gt; 0'>whether_network = #{whetherNetwork},</if><if test='softContent != null and softContent.length &gt; 0'>soft_content = #{softContent},</if><if test='issueType != null and issueType.length &gt; 0'>issue_type = #{issueType},</if><if test='softIp != null and softIp.length &gt; 0'>soft_ip = #{softIp},</if><if test='normalAccess != null and normalAccess.length &gt; 0'>normal_access = #{normalAccess},</if><if test='createTime != null and createTime.length &gt; 0'>create_time = #{createTime},</if><if test='userId != null '>user_id = #{userId},</if><if test='assetsStatus != null '>assets_status = #{assetsStatus},</if><if test='assetsType != null and assetsType.length &gt; 0'>assets_type = #{assetsType},</if><if test='sectionName != null and sectionName.length &gt; 0'>section_name = #{sectionName},</if><if test='sectionId != null'>section_id = #{sectionId},</if><if test='dataLabelsId != null '>data_labels_id = #{dataLabelsId},</if><if test='startProvisionDate != null and startProvisionDate.length &gt; 0'>start_provision_date = #{startProvisionDate},</if><if test='assetsClassificationId != null '>assets_classification_id = #{assetsClassificationId},</if><if test='assetsClassificationPid != null'>assets_classification_pid = #{assetsClassificationPid},</if><if test='selfBuilt != null '>self_built = #{selfBuilt},</if><if test='qualityAssurance != null '>quality_assurance = #{qualityAssurance},</if><if test='maintainUnit != null and maintainUnit.length &gt; 0'>maintain_unit = #{maintainUnit},</if><if test='developmentUnit != null and developmentUnit.length &gt; 0'>development_unit = #{developmentUnit}, </if><if test='assetDisposal != null '>asset_disposal = #{assetDisposal}, </if><if test='witbigName != null and witbigName.length &gt; 0'>witbig_name = #{witbigName}, </if><if test='witsmallName != null and witsmallName.length &gt; 0'>witsmall_name = #{witsmallName}, </if><if test='construcUnitName != null and construcUnitName.length &gt; 0'>construc_unit_name = #{construcUnitName}, </if><if test='buildUnitName != null and buildUnitName.length &gt; 0'>build_unit_name = #{buildUnitName}, </if><if test='maintainUnitName != null and maintainUnitName.length &gt; 0'>maintain_unit_name = #{maintainUnitName}, </if><if test='assetsTypeName != null and assetsTypeName.length &gt; 0'>assets_type_name = #{assetsTypeName}, </if><if test='assetsStatusName != null and assetsStatusName.length &gt; 0'>assets_status_name = #{assetsStatusName}, </if><if test='assetDisposalName != null and assetDisposalName.length &gt; 0'>asset_disposal_name = #{assetDisposalName}, </if><if test='lightGetBuildNum != null and lightGetBuildNum.length &gt; 0'>light_get_build_num = #{lightGetBuildNum},  </if><if test='lightGetSectionId != null and lightGetSectionId.length &gt; 0'>light_get_section_id = #{lightGetSectionId},  </if></set>where id = #{id}</script>"})
    int updateById(Assets assets);

    @Update({"<script>update assets set light_get_build_num = null,light_get_section_id = null where id = #{id}</script>"})
    int deleteLight(Integer num);

    @Update({"<script>update assets set start_provision_date = #{startProvisionDate},certificate_num=#{certificateNum}<where><if test='buildNum != null '>and  build_num = #{buildNum}  </if><if test='sectionId != null '>and  section_id = #{sectionId}  </if> </where></script>"})
    Integer updateStartProvisionDate(@Param("startProvisionDate") String str, @Param("certificateNum") String str2, @Param("buildNum") String str3, @Param("sectionId") Integer num);

    @Update({"<script>update assets set assets_classification_id=#{assetsClassificationId},assets_classification_pid = #{assetsClassificationPid}  where id = #{id} </script>"})
    Integer updAssetsClassificationId(@Param("id") String id, @Param("assetsClassificationId") Integer num, @Param("assetsClassificationPid") Integer assetsClassificationPid);

    @Delete({"delete from assets  where id = #{id} "})
    Integer deleteByIds(@Param("id") String id);

    @Update({"<script>update assets set asset_approval_status = #{assetApprovalStatus}<where><if test='buildNum != null '>and  build_num = #{buildNum}  </if><if test='sectionId != null '>and  section_id = #{sectionId}  </if> </where></script>"})
    int updassetApprovalStatus(@Param("assetApprovalStatus") Integer num, @Param("buildNum") String str, @Param("sectionId") Integer num2);

    @ResultMap({"map"})
    @Select({"<script>select t.*,t1.witbig_name as witbigName," +
            "t2.witsmall_name as witsmallName,t3.unit_name as buildUnitName ," +
            "t4.unit_name as construcUnitName,t5.unit_name as maintainUnitName," +
            "t6.name as assetsClassificationPName, t7.name as assetsClassificationName," +
            "t8.dict_name as assetsType from assets t   " +
            "LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  " +
            "LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND " +
            "t.big_num = t2.witbig_num and t2.type= t.device_type " +
            "LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type " +
            "LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   " +
            "LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num and t5.TYPE = t.device_type  " +
            "LEFT JOIN assets_classification t6 ON t.assets_classification_pid= t6.id   " +
            "LEFT JOIN assets_classification t7 ON t.assets_classification_id= t7.id   " +
            "LEFT JOIN (SELECT *  FROM dict_data " +
            "WHERE dict_type = 'assetsType') t8 ON t.assets_type= t8.dict_value  " +
            "<where> t.assets_status > -1 and t.asset_approval_status = 2 " +
            "<if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if>" +
            "<if test='name != null and name.length() &gt; 0'> and t.name like concat('%',#{name},'%') </if>" +
            "<if test='sectionId != null '> and t.section_id= #{sectionId} </if>" +
            "<if test='assetsClassificationId == 0 '> and t.assets_classification_id is null </if>" +
            "<if test='assetsClassificationId == 1 '> and t.assets_classification_id  is not null </if>" +
            "<if test='assetsType != null and assetsType.length() &gt; 0'> and t.assets_type = #{assetsType} </if>" +
            "</where>  </script>"})
    List<Assets> findByProject(@Param("buildNum") String buildNum, @Param("sectionId") Integer sectionId,
                               @Param("name") String name, @Param("assetsClassificationId") Integer assetsClassificationId,
                               @Param("assetsType") String assetsType);

    @Select({"<script>SELECT p.name as projectName,b.section_name as sectionName,b.name as assetName,b.combined as money,b.number,b.start_provision_date as stop_time,b.depreciation_year as depreciationYear FROM assets b left join project p ON b.build_num = p.project_no  <where>  b.assets_status > -1 and b.asset_approval_status = 2<if test='startTime != null and startTime.length &gt; 0 and endTime != null and endTime.length &gt; 0'>  b.start_provision_date between #{startTime} and  #{endTime} </if><if test='dataLabelsId != null '>and  b.data_labels_id = #{dataLabelsId}  </if><if test='assetsClassificationId != null '>and  b.assets_classification_id = #{assetsClassificationId}  </if><if test='assetsClassificationPid != null '>and  b.assets_classification_pid = #{assetsClassificationPid}  </if></where>ORDER BY b.start_provision_date</script>"})
    List<DepRate> depRateStatistics(@Param("startTime") String str, @Param("endTime") String str2, @Param("dataLabelsId") Integer num, @Param("assetsClassificationId") Integer num2, @Param("assetsClassificationPid") Integer num3);

    @Select({"SELECT SUM(combined) as amountTotal,SUM(number) as numberTotal FROM assets WHERE TO_DAYS(create_time) != TO_DAYS(NOW())  and assets_status > -1 and asset_approval_status = 2"})
    AssetsTotal getTotal();

    @Select({"SELECT  SUM(combined) as amountTotal,SUM(number) as numberTotal FROM assets WHERE DATE_FORMAT(create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')  and assets_status > -1 and asset_approval_status = 2"})
    AssetsTotal getMonthTotal();

    @Select({"SELECT  name,start_datetime as startDatetime,depreciation_year as depreciationYear,combined, IFNULL(start_provision_date,'') as startProvisionDate  FROM assets WHERE DATE_FORMAT(create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')   and assets_status > -1 and asset_approval_status = 2 ORDER BY id DESC"})
    List<MonthListVO> getMonthList();

    @Select({"SELECT ac.name,IFNULL(SUM(a.number),0) as numberSum,IFNULL(SUM(a.combined),0) as amountSum FROM (SELECT * FROM `assets_classification` WHERE pid = 0) ac LEFT JOIN  (SELECT number,combined,assets_classification_pid FROM assets WHERE TO_DAYS(create_time) != TO_DAYS(NOW()) and assets_status > -1 and asset_approval_status = 2 ) a  ON a.assets_classification_pid = ac.id  GROUP BY ac.id "})
    List<AssetsTypeSum> getAssetsTypeSumListOne();

    @Select({"select self_built as name,count(*) as numberSum from assets  WHERE  assets_status > -1 and asset_approval_status = 2    group by self_built "})
    List<AssetsTypeSum> getAssetsSelfBuilt();

    @Select({"SELECT ast.name,IFNULL(SUM(a.number),0) as numberSum,IFNULL(SUM(a.combined),0) as amountSum " +
            "FROM (SELECT * FROM `asset_type` ) ast " +
            "LEFT JOIN  (SELECT number,combined,assets_type " +
            "FROM assets WHERE TO_DAYS(create_time) != TO_DAYS(NOW()) " +
            "and assets_status > -1 and asset_approval_status = 2 ) a  " +
            "ON a.assets_type = ast.type  GROUP BY ast.type "})
    List<AssetsTypeSum> getAssetsTypeSumListTwo();

    @Select({"SELECT ast.name,IFNULL(SUM(a.number),0) as numberSum,IFNULL(SUM(a.combined),0) as amountSum FROM (SELECT * FROM `asset_type` ) ast LEFT JOIN  (SELECT number,combined,assets_type FROM assets WHERE create_time between #{startTime} and #{endTime} and assets_status > -1 and asset_approval_status = 2 ) a  ON a.assets_type = ast.type  GROUP BY ast.type "})
    List<AssetsTypeSum> getAssetsTypeSum(@Param("startTime") String str, @Param("endTime") String str2);

    @Select({"select d.dict_name as name,count(a.assets_status) as numberSum from assets a right join (select * from dict_data where dict_type = 'assetsStatus') d on a.assets_status = d.dict_value   group by d.dict_value "})
    List<AssetsTypeSum> getAssetsLifeCycle();

    @Select({"SELECT IFNULL(bb.count1,0) AS remark FROM calendar ca LEFT JOIN (SELECT DATE_FORMAT(create_time, '%Y-%m-%d') triggerDay,assets_status, COUNT(id) AS count1 FROM assets a WHERE assets_type = #{type} AND assets_status = #{assetsStatus} and assets_status > -1 and asset_approval_status = 2 AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(create_time) GROUP BY triggerDay,assets_status ORDER BY create_time) bb ON ca.`datelist`=bb.triggerDay WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= DATE(ca.datelist)&&DATE(ca.datelist)<=CURDATE()-1 "})
    List<String> discountChart(@Param("type") String str, @Param("assetsStatus") Integer num);

    @Select({"SELECT u.unit_name AS companyName,COUNT(a.build_unit) AS id  FROM assets a LEFT JOIN (SELECT *  FROM unit WHERE TYPE = #{type1}) u ON a.build_unit = u.unit_num WHERE a.assets_type = #{type} and a.assets_status > -1 and a.asset_approval_status = 2 and u.unit_name is not null GROUP BY  a.build_unit  ORDER BY id DESC"})
    List<Company> columnar(@Param("type") String str, @Param("type1") String str2);

    @Select({"<script>select t.id,t.asset_num as assetNum,t.pact_name as pactName," +
            "t1.witbig_name as witbigName,t2.witsmall_name as witsmallName," +
            "t.name,t.facility_ip as facilityIp,t.start_datetime as startDatetime," +
            "t.completion_time as completionTime,t.combined,t.depreciation_year as depreciationYear," +
            "t.quality_assurance as qualityAssurance,t.place,t.brand,t.models," +
            "t.responsible_police as responsiblePolice,t4.unit_name as construcName," +
            "t3.unit_name as buildName,t5.unit_name as maintainName," +
            "t.power_type as powerType,t.whether_enable as whetherEnable," +
            "t.whether_power as whetherPower,t.whether_network as whetherNetwork," +
            "t.remark,t.qr_code as qrCode from assets t   LEFT JOIN witbig  t1 ON " +
            "t.big_num=t1.`witbig_num` and t1.type= t.device_type  LEFT JOIN witsmall t2 " +
            "ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num " +
            "and t2.type= t.device_type LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  " +
            "and t3.TYPE = t.device_type LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 " +
            "ON t.construc_unit= t4.unit_num   LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num " +
            "and t5.TYPE = t.device_type " +
            "<where> " +
            "t.assets_type = #{type} " +
            "<if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if>" +
            "<if test='sectionId != null'> and t.section_id= #{sectionId} </if>" +
            "</where> ORDER BY t.id DESC </script>"})
    List<ExportHardwit> exportHardwit(@Param("buildNum") String buildNum,
                                      @Param("sectionId") Integer sectionId,
                                      @Param("type") String type);

    @Select({"<script>select t.id,t.asset_num as assetNum,t.pact_name as pactName," +
            "t1.witbig_name as witbigName,t2.witsmall_name as witsmallName,t.name," +
            "t.soft_content as softContent,t.issue_type as issueType," +
            "t.soft_ip as softIp,t.start_datetime as startTime," +
            "t.completion_time as completionTime,t.combined,t.depreciation_year as depreciationYear," +
            "t.quality_assurance as qualityAssurance,t.development_unit as developmentUnit," +
            "t.responsible_police as responsiblePolice,t4.unit_name as construcName," +
            "t3.unit_name as buildName,t5.unit_name as maintainName," +
            "t.whether_enable as whetherEnable,t.normal_access as normalAccess," +
            "t.remark,t.qr_code as qrCode from assets t   " +
            "LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  " +
            "LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num and t2.type= t.device_type " +
            "LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type " +
            "LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   " +
            "LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num and t5.TYPE = t.device_type " +
            "<where> " +
            "t.assets_type = #{type} <if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if>" +
            "<if test='sectionId != null'> and t.section_id= #{sectionId} </if>" +
            "</where> ORDER BY t.id DESC </script>"})
    List<ExportSoftWit> exportSoftwit(@Param("buildNum") String buildNum, @Param("sectionId") Integer sectionId, @Param("type") String type);

    @Select({"<script>select t.id,t.asset_num as assetNum,t.additional_number as additionalNumber,t.pact_name as pactName,t1.witbig_name as witbigName,t2.witsmall_name as witsmallName,t.name,t.models,t.brand,t.number,t.unit_price as unitPrice,t.combined,t4.unit_name as construcName,t3.unit_name as buildName,t.start_datetime as startDatetime,t.completion_time as completionTime,t.depreciation_year as depreciationYear,t.place as place,t.remark,t.qr_code as qrCode from assets t   LEFT JOIN witbig  t1 ON t.big_num=t1.`witbig_num` and t1.type= t.device_type  LEFT JOIN witsmall t2 ON t.small_num = t2.witsmall_num AND t.big_num = t2.witbig_num and t2.type= t.device_type LEFT JOIN unit t3 ON t.build_unit = t3.unit_num  and t3.TYPE = t.device_type LEFT JOIN (SELECT * FROM unit WHERE TYPE = 'zd') t4 ON t.construc_unit= t4.unit_num   LEFT JOIN unit t5 ON t.maintain_unit= t5.unit_num and t5.TYPE = t.device_type <where>  <if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if><if test='sectionId != null'> and t.section_id= #{sectionId} </if></where> ORDER BY t.id DESC </script>"})
    List<ExportBasics> exportBasics(@Param("buildNum") String buildNum, @Param("sectionId") Integer sectionId, @Param("type") String type);

    @Select({"<script>select t.id,t.asset_num as assetNum,t.name,t.purchase_type as purchaseType," +
            "t.get_datetime as getDatetime,t.brand as brand,t.serial_number as serialNumber," +
            "t.retailer as retailer,t.asset_type_name as assetTypeName,t.gaining_type as gainingType," +
            "t.purpose,t.models,t.manufacturer,t.start_datetime as startDatetime," +
            "t.guarantee_stop_datetime as guaranteeStopDatetime,t.depreciation_year as depreciationYear," +
            "t.money_type as moneyType,t.combined,t.depreciation_status as depreciationStatus," +
            "t.condition_status as conditionStatus,t.use_department as useDepartment," +
            "t.place,t.use_user as useUser,t.manage_department as manageDepartment," +
            "t.qr_code as qrCode from assets t  <where>  t.assets_type = #{type} " +
            "<if test='buildNum != null and buildNum.length() &gt; 0'> and t.build_num= #{buildNum} </if>" +
            "</where> ORDER BY t.id DESC </script>"})
    List<ExportPurchase> exportPurchase(@Param("buildNum") String buildNum, @Param("type") String type);

    @Select({"SELECT *  FROM `assets` where qr_code is  null"})
    List<Assets> test();

    @Update({"<script>UPDATE assets set\tasset_num=#{assetNum} where id IN <foreach collection='ids' item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach></script>"})
    Integer updateBatchAssetsNum(@Param("assetNum") String str, @Param("ids") String[] strArr);

    @Select({"SELECT assets_status  FROM `assets` where id = #{id}"})
    Integer getAssetsStatus(@Param("id") Integer num);

    @Update({"UPDATE assets set qr_code=#{qrCode}," +
            "qr_code_get_time = #{qrCodeGetTime}," +
            "qr_code_direct= #{qrCodeDirect}  where id = #{id}"})
    Integer generateCode(@Param("qrCode") String qrCode,
                         @Param("id") Integer id,
                         @Param("qrCodeGetTime") String qrCodeGetTime,
                         @Param("qrCodeDirect") Integer qrCodeDirect);

    @Select("SELECT qr_code  FROM `assets` where id = #{id}")
    String getQrCode(@Param("id") Integer id);

    @Update({"UPDATE assets set qr_code=#{qrCode} ,gmt_update = #{gmtUpdate} where id = #{id}"})
    Integer bindingCards(@Param("qrCode") String qrCode,
                         @Param("id") Integer id,
                         @Param("gmtUpdate") String gmtUpdate);
}